<template>
  <div class="Page Confirm">
    <div class="Title">
      <h1 class="fl f18">订单确认</h1>
      <img src="~/assets/img/cart_setp2.png" class="fr">
      <div class="clear"></div>
    </div>
    <form name="flowForm" id="flowForm" method="post" action="">
      <table class="GoodList">
        <tbody>
        <tr>
          <th class="name">商品</th>
          <th class="price">原价</th>
          <th class="priceNew">价格</th>
        </tr>
        </tbody>
        <tbody>
        <!-- <tr>
          <td colspan="3" class="Title red f18 fb"><p>限时折扣</p></td>
        </tr> -->
        <tr>
          <td colspan="3" class="teacher">讲师：<span style="color: orange;">{{order.teacherName}}</span></td>
        </tr>
        <tr class="good">
          <td class="name First">
            <a target="_blank" :href="'/course/'+order.courseId">
              <img :src="order.courseCover"></a>
            <div class="goodInfo">
              <input type="hidden" class="ids ids_14502" value="14502">
              <a target="_blank" :href="'/course/'+ order.courseId" style="color: orange;">{{order.courseTitle}}</a>
            </div>
          </td>
          <td class="price">
            <p>￥<strong>{{order.totalFee}}</strong></p>
            <!-- <span class="discName red">限时8折</span> -->
          </td>
          <td class="red priceNew Last">￥<strong>{{order.totalFee}}</strong></td>
        </tr>
        <tr>
          <td class="Billing tr" colspan="3">
            <div class="tr">
              <p>共 <strong class="red">1</strong> 件商品，合计<span
                class="red f20">￥<strong>{{order.totalFee}}</strong></span></p>
            </div>
          </td>
        </tr>
        </tbody>
      </table>
      <div class="Finish">
        <div class="clear"></div>
        <div class="Main fl">
          <div class="fl">
            <a :href="'/course/'+order.courseId">返回课程详情页</a>
          </div>
          <div class="fr">
            <p>共 <strong class="red">1</strong> 件商品，合计<span class="red f20">￥<strong
              id="AllPrice">{{order.totalFee}}</strong></span></p>
          </div>
        </div>
        <input name="score" value="0" type="hidden" id="usedScore">
        <button class="fr redb" type="button" id="submitPay" @click="toPay()">去支付</button>
        <div class="clear"></div>
      </div>
    </form>
  </div>
</template>

<script>

  import orderApi from '@/api/order'

  export default {

    data() {
      return {
        "order": ""
      }
    },
    created() {
      // 获取订单id
      if(this.$route.params && this.$route.params.orderId) {
        this.selectOrderInfo(this.$route.params.orderId);
      }
    },
    methods: {
      // 根据订单id获取订单详情
      selectOrderInfo(orderId) {
        // 校验orderId
        if(!orderId) {
          this.$message.error("订单id不能为空");
          return ;
        }
        orderApi.selectOrderInfo(orderId)
          .then(res => {
            if(res.data.code==200) {
              this.order=res.data.data.order;
            }else {
              this.$message.error(res.data.message);
            }
          });
      },
      // 支付
      toPay() {
        // 参数校验
        if(!this.order.orderNo) {
          this.$message.error("订单id不能为空");
          return ;
        }
        // 跳转到支付页面
        this.$router.push({"path": `/pay/${this.order.orderNo}`});
      }
    }

  }

</script>
